home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / A_HANDLR.S < prev    next >
Encoding:
Text File  |  1996-05-10  |  2.9 KB  |  101 lines

  1.     xdef    @handler
  2.  
  3. ;-------------------------------------------------------------------------------------
  4. ; AES/VDI (Trap 2)  Handler
  5. ;-------------------------------------------------------------------------------------
  6. ; This mini handler just calls the main handler (written in C) or fields VDI
  7. ; commands out to the old vector (which was saved when we hooked trap 2 in the first
  8. ; place).
  9. ; Perhaps the whole trap handler should be in assembler, but really, it's fast enough
  10. ; for me just written in C with this small kludge routine to handle the actual
  11. ; exception itself. If anyone wants to recode it totally in assembler, the main Trap
  12. ; to pipe interface in in HANDLER.C - I'll happily put the mods into a new release.
  13. ; - Self modifying code removed [13/2/96] by Martin koeling.
  14. ; - Made XBRA compliant [13/2/96] by Martin koeling.
  15. ;-------------------------------------------------------------------------------------
  16.  
  17.     section trap_handler,CODE
  18.  
  19.     xref    @XA_handler
  20.     xdef    _asm_hook_into_vector
  21.     xdef    _accstart
  22.  
  23. ; The hook is now done in assembler....
  24. _asm_hook_into_vector:
  25.     movem.l    d0-d2/a0-a1,-(a7)
  26.     pea        @handler(pc)
  27.     move.w    #$22,-(a7)
  28.     move.w    #5,-(a7)
  29.     trap    #13
  30.     lea        8(a7),a7
  31.     move.l    d0,_old_trap2_vector
  32.     movem.l    (a7)+,d0-d2/a0-a1
  33.     rts
  34.  
  35. ; XBRA structure immediately before the new vector address:
  36.     dc.b    'XBRA'
  37.     dc.b    'XaAE'        ; XBRA id (just a proposal)
  38. _old_trap2_vector:
  39.     dc.l    0
  40.     
  41. ;Exception vector goes to here....
  42. @handler:
  43.  
  44.     btst    #7,d0            ; Is this a VDI call? AES calls all have bit 7 of d0 set.
  45.     beq.s    _is_vdi_call    ; - if so, we should call the old vector as we haven't replaced
  46.                             ;   the VDI and have to rely on the existing one.
  47.  
  48.     cmp.w    #$fffe,d0        ; Bloody inconvenient vq_gdos() call - what's wrong with the normal VDI magic?
  49.     beq.s    _is_vdi_call
  50.     
  51.     cmp.w    #$c9,d0            ; Special case : implement the test for installed AES
  52.     beq.s    _end_handler
  53.     
  54.     movem.l    d0-d7/a0-a6,-(a7)
  55.  
  56.     move.l    d1,a0            ; Place d1 arg in a0 as Lattice __regargs expects pointer to be
  57.                             ; in a0 not d1
  58.  
  59.     jsr        @XA_handler        ; Call the real handler written in C
  60.  
  61.     movem.l    (a7)+,d0-d7/a0-a6
  62.  
  63.     clr.w    d0                ; Ordinary GEM does this - so we do it as well.....
  64.  
  65. _end_handler:
  66.     rte
  67.  
  68. ; New version of the call to the original VDI/AES vector
  69. ; [13/2/96] - Martin Koehling
  70. ; This is a jump to the old VDI/AES vector. No self-modifieng code
  71. ; here - _old_trap_vector is data, not code... :-)
  72. _is_vdi_call:
  73.     move.l    _old_trap2_vector(pc),-(sp)
  74.     rts
  75.  
  76. ; Accessory startup code poached from oAESis
  77. _accstart:
  78.     move.l 4(sp),a0
  79.     move.l 16(a0),a1
  80.     move.l a1,8(a0)
  81.     add.l  12(a0),a1
  82.     move.l a1,16(a0)
  83.     move.l 8(a0),a1
  84.     
  85.     movem.l    d0-d3/a0-a3,-(a7)
  86.     move.l    $c(a0),d0
  87.     add.l    $14(a0),d0
  88.     add.l    $1c(a0),d0
  89.     add.l    #512,d0
  90.     move.l    d0,-(a7)
  91.     move.l    a0,-(a7)
  92.     clr.w    -(a7)
  93.     move.w    #$4a,-(a7)
  94.     trap    #1
  95.     lea        12(a7),a7
  96.     movem.l    (a7)+,d0-d3/a0-a3
  97.     
  98.     jmp (a1)
  99.  
  100.     
  101.     END